from Crypto.Cipher import AES
from base64 import b64decode, b64encode, urlsafe_b64encode, urlsafe_b64decode
from Crypto.Util.Padding import pad, unpad


text = "汪汪特工队"
k = "uMOQkzkXv/qzUz1XZ2ko+A=="
# k = "uMOQkzkXv/+A=="
ks = "870794bc135c41349bd4214854fc9b1c"


def encrypt(text):
    text = pad(text.encode(), block_size=AES.block_size)
    cipher = AES.new(k.encode(), AES.MODE_ECB)
    etext = cipher.encrypt(text)
    s = b64encode(etext).decode()
    return s


def decrypt(etext):
    cipher = AES.new(k.encode(), AES.MODE_ECB)
    text = cipher.decrypt(b64decode(etext))
    s = unpad(text, cipher.block_size).decode()
    return s


print(encrypt(text=text))
print(decrypt(encrypt(text=text)))
# print(decrypt("e+hV2PZU9Yag9iw/M8P5p3pG+xDXHrwiL6h96m+ZiWc="))
